<template>
    <div style="" @click="getParent($event)" :class="{'tab-item': !noScroll, 'no-scroll-item': noScroll}" class="">
        <slot></slot>
    </div>
</template>

<script>
export default {
    name: 'tabItem',
    data() {
        return {
            noScroll: false //默认不显示滚动
        };
    },
    methods: {
        getParent() {
            this.$parent.isIndexOf(this.currentIndex);
            /*
            * 回调组价点击方法 回传当前tab的index
            * */
            this.$emit('on-item-click', this.currentIndex);
        }
    },
    mounted() {
        /*
        * 调用父组件的更新方法
        * */
        this.$parent.updateIndex();
        /*
        * 是否是滚动模式
        * */
        this.noScroll = this.$parent.noScroll;
        /*当第一参数存在时*/
        if (this.currentIndex === 0) {
            this.getParent();
        }
    }
};
</script>

<style scoped>
.no-scroll-item{
    flex:1;
    position: relative;
}
.tab-item{
    height: 100%;
    display: inline-block;
    text-align: center;
    line-height: 50px;
    padding: 0 10px;
    font-size: 15px;
}
.tab-item.cur{
    color: #075ebb!important;
}
.no-scroll-item div {
    font-size: 16px;
    display: flex;
    justify-content:center;
    align-items: center;
    background: #F6F6F6;
    position: absolute;
    height: 100%;
    width: 100%;
}
</style>
